home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / archives / com / internet / sting / sting.lzh / STING / dev-kit / header / port.h < prev    next >
C/C++ Source or Header  |  1997-09-19  |  7KB  |  151 lines

  1. /*
  2.  *      port.h              (c) Peter Rottengatter  1996
  3.  *                              perot@pallas.amp.uni-hannover.de
  4.  *
  5.  *      Include this file to provide port interfacing to STinG
  6.  */
  7.  
  8. #ifndef STING_PORT_H
  9. #define STING_PORT_H
  10.  
  11. #ifndef MODULE_DRIVER
  12. #define MODULE_DRIVER    "MODULE_LAYER"
  13. #endif
  14.  
  15.  
  16.  
  17. /*--------------------------------------------------------------------------*/
  18.  
  19.  
  20. /*
  21.  *   Internal port descriptor.
  22.  */
  23.  
  24. typedef  struct port_desc {
  25.     char      *name;            /* Name of port                             */
  26.     int16     type;             /* Type of port                             */
  27.     int16     active;           /* Flag for port active or not              */
  28.     uint32    flags;            /* Type dependent operational flags         */
  29.     uint32    ip_addr;          /* IP address of this network adapter       */
  30.     uint32    sub_mask;         /* Subnet mask of attached network          */
  31.     int16     mtu;              /* Maximum packet size to go through        */
  32.     int16     max_mtu;          /* Maximum allowed value for mtu            */
  33.     int32     stat_sd_data;     /* Statistics of sent data                  */
  34.     IP_DGRAM  *send;            /* Link to first entry in send queue        */
  35.     int32     stat_rcv_data;    /* Statistics of received data              */
  36.     IP_DGRAM  *receive;         /* Link to first entry in receive queue     */
  37.     int16     stat_dropped;     /* Statistics of dropped datagrams          */
  38.     struct drv_desc   *driver;  /* Driver program to handle this port       */
  39.     struct port_desc  *next;    /* Next port in port chain                  */
  40.  } PORT;
  41.  
  42.  
  43. /*
  44.  *   Port driver descriptor.
  45.  */
  46.  
  47. typedef  struct drv_desc {
  48.     int16 cdecl  (* set_state) (PORT *, int16);  /* Setup and shutdown port */
  49.     void  cdecl  (* send) (PORT *);              /* Send pending packets    */
  50.     void  cdecl  (* receive) (PORT *);           /* Receive pending packets */
  51.     char             *name;     /* Name of driver                           */
  52.     char             *version;  /* Version of driver in "xx.yy" format      */
  53.     uint16           date;      /* Compile date in GEMDOS format            */
  54.     char             *author;   /* Name of programmer                       */
  55.     struct drv_desc  *next;     /* Next driver in driver chain              */
  56.  } DRIVER;
  57.  
  58.  
  59.  
  60. /*--------------------------------------------------------------------------*/
  61.  
  62.  
  63. /*
  64.  *   Link Type Definitions
  65.  */
  66.  
  67. #define  L_INTERNAL   0           /* Internal pseudo port                   */
  68. #define  L_SER_PTP    1           /*   Serial point to point type link      */
  69. #define  L_PAR_PTP    2           /* Parallel point to point type link      */
  70. #define  L_SER_BUS    3           /*   Serial            bus type link      */
  71. #define  L_PAR_BUS    4           /* Parallel            bus type link      */
  72. #define  L_SER_RING   5           /*   Serial           ring type link      */
  73. #define  L_PAR_RING   6           /* Parallel           ring type link      */
  74. #define  L_MASQUE     7           /*   Masquerading pseudo port             */
  75.  
  76.  
  77.  
  78. /*--------------------------------------------------------------------------*/
  79.  
  80.  
  81. /*
  82.  *   Module driver structure / functions
  83.  */
  84.  
  85. #ifndef MOD_DRIVER
  86. #define MOD_DRIVER
  87.  
  88. typedef  struct stx {
  89.     char *     module;      /* Specific string that can be searched for     */
  90.     char *     author;      /* Any string                                   */
  91.     char *     version;     /* Format `00.00' Version:Revision              */
  92.     void       cdecl  (* set_dgram_ttl) (IP_DGRAM *);
  93.     int16      cdecl  (* check_dgram_ttl) (IP_DGRAM *);
  94.     int16      cdecl  (* load_routing_table) (void);
  95.     int32      cdecl  (* set_sysvars) (int16, int16);
  96.     void       cdecl  (* query_chains) (void **, void **, void **);
  97.     int16      cdecl  (* IP_send) (uint32, uint32, uint8, uint16, uint8, uint8, uint16,
  98.                                    void *, uint16, void *, uint16);
  99.     IP_DGRAM * cdecl  (* IP_fetch) (int16);
  100.     int16      cdecl  (* IP_handler) (int16, int16 cdecl (*) (IP_DGRAM *), int16);
  101.     void       cdecl  (* IP_discard) (IP_DGRAM *, int16);
  102.     int16      cdecl  (* PRTCL_announce) (int16);
  103.     int16      cdecl  (* PRTCL_get_parameters) (uint32, uint32 *, int16 *, uint16 *);
  104.     int16      cdecl  (* PRTCL_request) (void *, void *);
  105.     void       cdecl  (* PRTCL_release) (int16);
  106.     void *     cdecl  (* PRTCL_lookup) (int16, void *);
  107.     int16      cdecl  (* TIMER_call) (void cdecl (*) (void), int16);
  108.     int32      cdecl  (* TIMER_now) (void);
  109.     int32      cdecl  (* TIMER_elapsed) (int32);
  110.     int32      cdecl  (* protect_exec) (void *, int32 cdecl (*) (void *));
  111.     int16      cdecl  (* get_route_entry) (int16, uint32 *, uint32 *, PORT **, uint32 *);
  112.     int16      cdecl  (* set_route_entry) (int16, uint32, uint32, PORT *, uint32);
  113.  } STX;
  114.  
  115. extern STX *stx;
  116.  
  117.  
  118. /*
  119.  *   Definitions of module driver functions for direct use
  120.  */
  121.  
  122. #define set_dgram_ttl(x)                 (*stx->set_dgram_ttl)(x)
  123. #define check_dgram_ttl(x)               (*stx->check_dgram_ttl)(x)
  124. #define load_routing_table()             (*stx->load_routing_table)()
  125. #define set_sysvars(x,y)                 (*stx->set_sysvars)(x,y)
  126. #define query_chains(x,y,z)              (*stx->query_chains)(x,y,z)
  127. #define IP_send(a,b,c,d,e,f,g,h,i,j,k)   (*stx->IP_send)(a,b,c,d,e,f,g,h,i,j,k)
  128. #define IP_fetch(x)                      (*stx->IP_fetch)(x)
  129. #define IP_handler(x,y,z)                (*stx->IP_handler)(x,y,z)
  130. #define IP_discard(x,y)                  (*stx->IP_discard)(x,y)
  131. #define PRTCL_announce(x)                (*stx->PRTCL_announce)(x)
  132. #define PRTCL_get_parameters(w,x,y,z)    (*stx->PRTCL_get_parameters)(w,x,y,z)
  133. #define PRTCL_request(x,y)               (*stx->PRTCL_request)(x,y)
  134. #define PRTCL_release(x)                 (*stx->PRTCL_release)(x)
  135. #define PRTCL_lookup(x,y)                (*stx->PRTCL_lookup)(x,y)
  136. #define TIMER_call(x,y)                  (*stx->TIMER_call)(x,y)
  137. #define TIMER_now()                      (*stx->TIMER_now)()
  138. #define TIMER_elapsed(x)                 (*stx->TIMER_elapsed)(x)
  139. #define protect_exec(x,y)                (*stx->protect_exec)(x,y)
  140. #define get_route_entry(a,b,c,d,e)       (*stx->get_route_entry)(a,b,c,d,e)
  141. #define set_route_entry(a,b,c,d,e)       (*stx->set_route_entry)(a,b,c,d,e)
  142.  
  143. #endif /* MOD_DRIVER */
  144.  
  145.  
  146.  
  147. /*--------------------------------------------------------------------------*/
  148.  
  149.  
  150. #endif /* STING_PORT_H */
  151.